/* @(#)GSUnBalanceDetailModifyAction.java
 * 
 *  Project:GS
 *  
 *  Modify  Information:
 *  ===============================================
 *   Author          Date            Description
 *  -------------- ---------------  ---------------
 *  Jenny  Li      2006-5-15          新增
 *  Jenny  Li      2006-6-5           修改关于结算截至日期的取得
 * Copyright Notice:
 * =============================================================================
 *    Copyright (c) 2001-2006 Beijing HiTRUST Technology Co., Ltd. 1808 Room, 
 *        Science & Technology Building, No. 9 South Street, Zhong Guan Cun, 
 *        Haidian District, Beijing ,100081, China All rights reserved.
 *
 *    This software is the confidential and proprietary information of
 *        Beijing HiTRUST Technology Co., Ltd. ("Confidential Information").
 *        You shall not disclose such Confidential Information and shall use it
 *        only in accordance with the terms of the license agreement you entered
 *        into with HiTRUST.
 *
 * Warning:
 * =============================================================================
 *
 */
package com.hitrust.gs.action;

import java.util.ArrayList;
import com.hitrust.gs.bean.GSBalanceMsgBean;
import com.hitrust.gs.bean.GSOrderBean;
import com.hitrust.gs.business.GSOrderProcessor;
import com.hitrust.gs.dao.GSBalanceMsgDAO;
import com.hitrust.gs.dao.GSOrderDAO;
import com.hitrust.gs.lib.GSBaseConstants;
import com.hitrust.gs.service.GSBaseAction;
import com.hitrust.gs.service.GSBaseForm;
import com.hitrust.gs.util.exception.GSException;

public class GSUnBalanceDetailModifyAction extends GSBaseAction {

	public String execute(GSBaseForm aForm) throws Exception {
        //取得参数订单编号
      String obj = aForm.getRequest().getParameter("params");
      try {
          String tStr[] = obj.split(",");
          String tOrderId = tStr[1];
          String tOrderDetailId = tStr[0];
          GSOrderProcessor tGSOrderProc = new GSOrderProcessor();
          //由订单编号查询订单及所订产品明细
          ArrayList tList = tGSOrderProc.getOrderDetailForBalanceSignInfo(tOrderId,tOrderDetailId);
          if(tList.size() > 0){
              aForm.getRequest().setAttribute("curorderdetail",tList.get(0));
          }
          GSOrderDAO tOrderDAO = new GSOrderDAO();
          //由订单编号查询订单信息
          GSOrderBean tBean = tOrderDAO.getOrderByTempID(tOrderId);
          aForm.getRequest().setAttribute("orderbean", tBean);
          //隐藏查询参数,暂无用
          aForm.getRequest().setAttribute("orderDetailId",tStr[0]);
          aForm.getRequest().setAttribute("orderId",tStr[1]);
          if(tStr[8].equals(GSBaseConstants.BALANCE_ORDERDEPT_TYPE)){
        	  aForm.getRequest().setAttribute("providerName",tStr[2]);
          }else if(tStr[8].equals(GSBaseConstants.BALANCE_PROVIDER_TYPE)){
        	  aForm.getRequest().setAttribute("orderDeptId",tStr[2]);  
          }
/*          //取得系统设定的结算结束日期
          GSBalanceParamDAO tBalParmDAO = new GSBalanceParamDAO();
          GSBalanceParamBean tBalParmBean = tBalParmDAO.queryBalanceDate();
          if(tBalParmBean.getGs_balance_date_type().equals(GSBaseConstants.NATURE_BALANCE_DATE)){
              String tCurDay = DateUtil.getCurrentDate("yyyyMMdd");
              int maxday = DateUtil.getMaxMonthDay(tCurDay);
              tBalParmBean.setGs_balance_end_date(String.valueOf(maxday));
              aForm.getRequest().setAttribute("balanceenddate",DateUtil.getSpecDay(maxday));
          }else{
              aForm.getRequest().setAttribute("balanceenddate",DateUtil.getSpecDay(Integer.parseInt(tBalParmBean.getGs_balance_end_date())));
              
          }
*/         
          GSBalanceMsgDAO tBalMsgDAO = new GSBalanceMsgDAO();
          ArrayList tBalMsgList = tBalMsgDAO.queryBalanceInfo(tStr[9],tStr[10]);
          if(tBalMsgList.size() == 1){
              GSBalanceMsgBean tBalMsgBean = (GSBalanceMsgBean)tBalMsgList.get(0);
              aForm.getRequest().setAttribute("balanceenddate",tBalMsgBean.getGs_end_date());
          }else{
              throw new GSException(GSException.E40012,GSException.E40012_MSG);
          }
          aForm.getRequest().setAttribute("concentricityId",tStr[4]);
          aForm.getRequest().setAttribute("manufinfo",tStr[5]);
          aForm.getRequest().setAttribute("orderDeliverDateStr",tStr[6]);
          aForm.getRequest().setAttribute("orderDeliverDateEnd",tStr[7]);
          aForm.getRequest().setAttribute("deptCategory",tStr[8]);
          aForm.getRequest().setAttribute("deptId",tStr[9]);
          aForm.getRequest().setAttribute("balanceYM",tStr[10]);
      }
      catch (Exception e) {
          aForm.getRequest().setAttribute("action","login.do");
          aForm.getRequest().setAttribute("window","true");//为出现异常准备参数
          throw e;
      }
      return GSBaseConstants.FORWARD_SUCCESS;
	}

}
